#env
echo "----------------------------BEFORE----------------------------"
#. jdk/make/jdk_generic_profile.sh
echo "----------------------------AFTER----------------------------"

#env
#exit 1

export ALT_BOOTDIR=D:/Software/Java/jdk1.6
export ALT_JDK_IMPORT_PATH=D:/Software/Java/jdk1.6
export ANT_HOME=D:/Development/apache-ant-1.8.4
export BUILD_LANGTOOLS=true
export BUILD_HOTSPOT=true
export BUILD_JDK=true
export BUILD_CORBA=false
export BUILD_JAXP=false
export BUILD_JAXWS=false
export SKIP_COMPARE_IMAGES=true
export SKIP_DEBUG_BUILD=false
export SKIP_FASTDEBUG_BUILD=true
export DEBUG_NAME=debug
export USE_PRECOMPILED_HEADER=true
export ARCH_DATA_MODEL=64
export HOTSPOT_BUILD_JOBS=16
export ALT_PARALLEL_COMPILE_JOBS=16
export BUILD_DEPLOY=false
export BUILD_INSTALL=false
export ALLOW_DOWNLOADS=true
export ALT_FREETYPE_HEADERS_PATH=D:/Workspace/CLionWorkspace/freetype-2.6.1-vs2010/include
export ALT_FREETYPE_LIB_PATH=D:/Workspace/CLionWorkspace/freetype-2.6.1-vs2010/lib
export WINDOWSSDKDIR="C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/"

export VSINSTALLDIR=D:/Software/MicrosoftVisualStudio/2010/
export MSVCDIR=${VSINSTALLDIR}/VC/
export VS100COMNTOOLS=${VSINSTALLDIR}/Common7/Tools

export LIBPATH="${MSVCDIR}/LIB/amd64;${MSVCDIR}/ATLMFC/LIB/amd64"
export INCLUDE="${MSVCDIR}/INCLUDE;${MSVCDIR}/ATLMFC/INCLUDE;${WINDOWSSDKDIR}/include"
export LIB="${MSVCDIR}/LIB/amd64;${MSVCDIR}/ATLMFC/LIB/amd64;${WINDOWSSDKDIR}/lib/x64"
EXTRA_PATH="${MSVCDIR}/bin/amd64;${WINDOWSSDKDIR}/Bin;${WINDOWSSDKDIR}/Bin/x64"
a=`cygpath  -p ${EXTRA_PATH}`
cygpath_short="/usr/bin/cygpath -m -s"
cygpath="/usr/bin/cygpath"
pathsep=":"
awk=gawk

removeDeadDups() # string sep
{
  set -e
  sep="$2"
  pathlist="1.txt"
  printf "%s\n" "$1" | \
    sed -e 's@\\@/@g' | \
    sed -e 's@//@/@g' | \
    ${awk} -F"${sep}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}'  \
      > ${pathlist}
  upaths="2.txt"
  cat ${pathlist} | while read orig; do
    p="${orig}"
    if [ "${cygpath_short}" != "" ] ; then
      if [ "${p}" != "" ] ; then
        if [ -d "${p}" ] ; then
          short=`${cygpath_short} "${p}"`
          if [ "${short}" != "" -a -d "${short}" ] ; then
            p=`${cygpath} "${short}"`
          fi
          echo "${p}" >> ${upaths}
        fi
      fi
    fi
  done
  newpaths=""
  for i in  `cat ${upaths}` ; do
    # For some reason, \r characters can get into this
    i=`echo "${i}" | tr -d '\r' | sed -e 's@/$@@'`
    if [ "${newpaths}" = "" ] ; then
      newpaths="${i}"
    else
      newpaths="${newpaths}${sep}${i}"
    fi
  done
  printf "%s\n" "${newpaths}" | \
    ${awk} -F"${sep}" \
       '{a[$1];printf "%s",$1;for(i=2;i<=NF;i++){if(!($i in a)){a[$i];printf "%s%s",FS,$i;}};printf "\n";}'
}

PATH=`removeDeadDups "${a}${pathsep}${PATH}" "${pathsep}"`
export PATH
echo $PATH

unset JAVA_HOME
#make sanity  | tee sanity.log
make V=1 debug_build DISABLE_HOTSPOT_OS_VERSION_CHECK=OK | tee build.log